package org.yabam.model;

import java.util.List;

import org.yabam.dao.DAOFactory;
import org.yabam.dao.DefaultDAO;

public class Owner {
	private String login;

	private String name;

	private String password;

	private String emailAddress;

	private final static DefaultDAO<Owner> dao = DAOFactory.getOwnerDAO();

	/**
	 * @param login
	 * @param name
	 */
	public Owner(String login, String name, String emailAddress, String password) {
		super();
		this.login = login;
		this.name = name;
		this.password = password;
		this.setEmailAddress(emailAddress);
	}

	/**
	 *
	 */
	public Owner() {
		super();
	}



	/**
	 * @param emailAddress the emailAddress to set
	 */
	public void setEmailAddress(String emailAddress) {
		this.emailAddress = emailAddress;
	}

	/**
	 * @return the emailAddress
	 */
	public String getEmailAddress() {
		return emailAddress;
	}

	/**
	 * @param password the password to set
	 */
	public void setPassword(String password) {
		this.password = password;
	}

	/**
	 * @return the password
	 */
	public String getPassword() {
		return password;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	/**
	 * @return the login
	 */
	public String getLogin() {
		return login;
	}

	/**
	 * @param login the login to set
	 */
	public void setLogin(String login) {
		this.login = login;
	}

	/**
	 * Delete this owner
	 *
	 * @see org.yabam.dao.DefaultDAO#delete(org.yabam.model.Owner)
	 */
	public void delete() {
		dao.delete(this);
	}

	/**
	 *Get the owner for that userName.
	 *
	 * @param userName
	 * @return
	 * @see org.yabam.dao.DefaultDAO#get(java.lang.String)
	 */
	public static Owner get(String userName) {
		return dao.get(userName);
	}

	/**
	 * Get all the owners.
	 *
	 * @return
	 * @see org.yabam.dao.DefaultDAO#getAll()
	 */
	public static List<Owner> getAll() {
		return dao.getAll();
	}

	/**
	 * Save or Update that owner.
	 *
	 * @see org.yabam.dao.DefaultDAO#saveOrUpdate(org.yabam.model.Owner)
	 */
	public void saveOrUpdate() {
		dao.saveOrUpdate(this);
	}
}
